	var map;
	var locMarker;//定位

	var normalm = L.tileLayer.chinaProvider('TianDiTu.Normal.Map', {
			maxZoom: 18,
			minZoom: 5
		}),
		normala = L.tileLayer.chinaProvider('TianDiTu.Normal.Annotion', {
			maxZoom: 18,
			minZoom: 5
		}),
		imgm = L.tileLayer.chinaProvider('TianDiTu.Satellite.Map', {
			maxZoom: 18,
			minZoom: 5
		}),
		imga = L.tileLayer.chinaProvider('TianDiTu.Satellite.Annotion', {
			maxZoom: 18,
			minZoom: 5
		});

	var normal = L.layerGroup([normalm, normala]),
		image = L.layerGroup([imgm, imga]);

	var baseLayers = {
		"地图": normal,
		"影像": image,
	}
    map = L.map('map', {
        center : centerPoint,
        zoom : defaultLevel,
        layers: [normal],
        fullscreenControl: {
            pseudoFullscreen: false
        }
    });

  /*  var noramlUrl= mapServerUrl + "/ZJLWSL/ZJLWSL/default/ZJLWSL/{z}/{y}/{x}.png";
    var normalMap = L.tileLayer(noramlUrl, {
        subdomains: [],
        minZoom:0,
        maxZoom:20,
        zoomOffset:0,
        tms:false
    });

    var imageUrl = mapServerUrl + "/ZJLWYX/ZJLWYX/default/ZJLWYX/{z}/{y}/{x}.png";
    var imageMap = L.tileLayer(imageUrl, {
        subdomains: [],
        minZoom:0,
        maxZoom:20,
        zoomOffset:0,
        tms:false
    });

    var res = [];
    for (var i = 0; i < 20; i++) {
        res[i] = 1.4062500262315825 / Math.pow(2, i);
    }
    var crs = new L.Proj.CRS("EPSG:4326","+proj=longlat +datum=WGS84 +no_defs", {
        origin: [-180,90],
        resolutions: res

    });

    crs.distance = function (latlng1, latlng2) {
        var rad = Math.PI / 180,
            R = 6378137,
            lat1 = latlng1.lat * rad,
            lat2 = latlng2.lat * rad,
            a = Math.sin(lat1) * Math.sin(lat2) +
                Math.cos(lat1) * Math.cos(lat2) * Math.cos((latlng2.lng - latlng1.lng) * rad);
        return R * Math.acos(Math.min(a, 1));
    };


    map = L.map('map', {
        center : centerPoint,
        zoom : defaultLevel,
        crs : crs,
        layers: [normalMap],
        fullscreenControl: {
            pseudoFullscreen: false
        }
    });

    var baseLayers = {
        "矢量": normalMap,
        "影像": imageMap,
    };*/


    //坐标位置
    L.control.mousePosition().addTo(map);
    //地图比例尺
    L.control.scale({metric:true,imperial:false}).addTo(map);

    L.control.layers(baseLayers).addTo(map);


    map.pm.addControls({
        cutPolygon:false,
        drawRectangle: false,
        drawCircle: false,
        drawMarker: false,
        drawPolygon: false,
        editPolygon: true,
        drawPolyline: false,
        deleteLayer: true
    });

    //鹰眼图
    /*var osmAttrib='Map data &copy; OpenStreetMap contributors';
    var osm2 = new L.TileLayer(noramlUrl, {minZoom: 0, maxZoom: 20, attribution: osmAttrib });
    var miniMap = new L.Control.MiniMap(osm2, { toggleDisplay: true , minimized: true}).addTo(map);*/

    //上传文件
    function showUploadWindow() {
        $('#importDlg').window('open');
    }
    var uploadUrl = "/regionAllot/upLoadFile";
    function  toUpLoad() {
        $('#uploadForm').form('submit', {
            url:uploadUrl,
            onSubmit: function(){
                // do some check
                // return false to prevent submit;
            },
            success:function(data){
                //window.close();
                var filename = data;
                drawShpZipMap(filename);
                $('#importDlg').window('close');
            }
        });
    }
    //保存当前上传的地图到后台
    function  toSaveMap() {
        //获取选取tree节点Id
        var jgid = parent.getSelectedId();
        $('#jgid').val(jgid);
        $('#ff').form({
            url:"/regionAllot/savePolygonMap",
            onSubmit: function(){
                // do some check
                // return false to prevent submit;
            },
            success:function(data){
                window.parent.reloadTree();
                if(data=="true"){
                    layer.msg("保存成功！");
                }else{
                    layer.msg("保存失败！");
                }
            }
        });
        // submit the form
        $('#ff').submit();
    }


